<%--
	fileName      : usermgmt_menu.jsp
	author        : kfzx-yuli1
	createDate    : 2010-6-10  上午12:52:23
	lastModifier  : kfzx-yuli1
	lastModifyDate: 2010-6-10  上午12:52:23
	description   : 请添加描述
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="ctp-tag" prefix="ctp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>菜单列表</title>
		<ctp:include items='borderlayout,panel,toolbar,textfield,editable,tabletree,button,message_ex'/>
		<script type="text/javascript" src="../js/ctp/public/jsextend.js"></script>
		

        	
		<script type='text/javascript' kind='variant'>	
			  
		    //================================UI变量定义片段============================================================
		//			ctp.core.log.lvl=ctp.core.loglvl.obj;
			var shortcutmentToolBar,shortcutmentTabletree,shortcutmentGridBody,shortcutmentPanel;
			var borderlayout;
		</script>		
		<script type='text/javascript' kind='event'>
		var myurl;
		var userId;
            //================================函数定义片段============================================================
			function init(){
				userId='<ctp:out name="userId"/>';
			
			}
		
		
		
		
			 /**
             * 回调函数，删除后刷新表树
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-yuli1           
             */
			
				
				
		       function handler_operation(){
		       var _mContext = "usermgmt.jsp -> handler_operation()";  
		  	  	   try {  
		       				//删除成功后刷新表树和重置按钮状态
		                   	shortcutmentTabletree.reload(myurl);
		                	shortcutmentTabletree.refreshJsonVal();
		                	$.editable.refreshJson();
		                	
		             }
		    	    catch (e) {
		      	               ctp.core.log.err(_mContext, e.message);
		            }             
		     	}
			

        </script>
		<script type='text/javascript' kind='ui'>
		    //================================UI组件定义片段============================================================		    
		    //ctp.core.log.lvl = ctp.core.loglvl.obj; //需要进行调试时启用
		    /**
             * 创建UI组件
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-yuli1           
             */		    
		    function initUI(){				
				shortcutmentToolBar=new ctp.ui.toolbar({
					id : 'shortcutmentToolBar',			
					border : 'bottom',			
	            	leftItems :[{
							id:"_toolbar_button_confirm",
		                	type : 'button',
		                	text : '<ctp:label key="yesbutton" />',
		                	icon : 'apply',
		                	disabled : false,
		                	onClick : function(){
		                		$.editable.submitUnit(shortcutmentTabletree);//允许最后一次修改不回车直接提交

				                var menuData = ctp.data.jsonToStr(shortcutmentTabletree.getJsonVal());
				                
				                if(!shortcutmentTabletree.getJsonVal().length){//判断json内容是否为空，临时这样写，等有方法判断之后替换
				                	return;
				                }
				           		var retData = ctp.data.getJSON('<ctp:url href="user.flowc" flowActionName="modifymenuop"/>&userId='+userId,{"json.itemList":menuData});
		                		if(retData[0].out_flag && retData[0].out_flag=='0'){
		                			ctpMSB.succeed({title:'<ctp:label key="operation_result_title"/>',message:'<ctp:label key="adjust_usermenu_success"/>',handler: handler_operation});

		                		}else{
		                			ctpMSB.error({title:'<ctp:label key="operation_result_title"/>',message:'<ctp:label key="adjust_usermenu_fail"/>'});
		                		}	
				                

				             }
							},'-',{
							id:"_toolbar_button_cancel",
		                	type : 'button',
		                	text : '<ctp:label key="returnbutton" />',
		                	icon : 'back',
		                	disable : false,
		                	onClick : function(){
		                			history.go(-1);
		                		}
		                }]		   
			    });
				myurl='<ctp:url href="user.flowc" flowActionName="getusermenuop"/>&userId='+userId;
			    shortcutmentTabletree = new ctp.ui.tabletree({
			    	actionPos:1,
			    	check:false,
					height: 'auto',
			    	tableHead:[[
			    	{text:'<ctp:label key="module_name"/>'},	//模块名称
			    	{text:'<ctp:label key="module_code"/>'},	//模块代码
			    	{text:'<ctp:label key="state"/>'},			//状态
			    	{text:'<ctp:label key="auth"/>',edit:{fieldName:'choice',fieldType:'select',config:{options:{items:[{text:'<ctp:label key="first_use"/>',value:'1'},{text:'<ctp:label key="forbid"/>',value:'0'},{text:'<ctp:label key="can_select"/>',value:'-1'}]}}}} //权限
			    	]],
			    	url:myurl,
			    	id:'shortcutmentTabletree'
			    });
			    shortcutmentPanel = new ctp.ui.panel({
					id: 'shortcutmentPanel',
		            title: '<ctp:label key="menu_select"/>',
		            items:[shortcutmentTabletree],
		            collapsible: true,
				    width: 'auto',
				    bodyPadding:'0',
				    toolbar:shortcutmentToolBar,
                    toolbarPos:'outertop',	
				   	//visible: 'visible',
				   	height: '100%'
		        });
			    borderlayout=new ctp.ui.borderlayout({
                    type: "1C",                    
                    center__size: "auto",
                    center__items:[shortcutmentPanel],
                    renderTo:'body'
                }); 			    
			}
			
		</script>
	</head>
	<body onload="init();initUI()">
		<ctp:form name="GotoShortCutMenuList" method="post" action="user.flowc" flowActionName="modifymenuop">
			<input type="hidden" name="json_itemList">
		</ctp:form>
		
		
	</body>
</html>

<%--
	date        :
	modifyReason:
--%>